<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<link href="<%=request.getContextPath()%>/static/css/font-awesome.min.css"
	rel="stylesheet">
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="<%=request.getContextPath()%>/">好室友</a>
        </div>
        
        <c:if test="${user eq null }">
        <div id="navbar" class="navbar-collapse collapse">
          <form class="navbar-form navbar-right" method="post" action="<%=request.getContextPath()%>/Account/Login">
            <input type="hidden" name="action" value="login" />
            <div class="form-group">
              <input type="text" placeholder="账户" name="username" class="form-control">
            </div>
            <div class="form-group">
              <input type="password" placeholder="密码" name="password" class="form-control">
            </div>
            <button type="submit" class="btn btn-success">立即登陆</button>
            <a class="btn btn-info" href="<%=request.getContextPath() %>/Account/Register">马上注册</a>
          </form>
        </div><!--/.navbar-collapse -->
		</c:if>
		<c:if test="${user ne null }">
		<div id="navbar" class="navbar-collapse collapse">
		  <ul class="nav navbar-nav navbar-right">
		    <li><a>欢迎您，<b>${fn:escapeXml(user.username) }</b>！</a></li>
		    <li class="dropdown">
		      <a href="#" class="dropdown-toggle" data-toggle="dropdown">
		        <span class="glyphicon glyphicon-bell"></span>
		                    消息中心
		      </a>
		    </li>
		    <li class="dropdown">
		      <a href="#" class="dropdown-toggle" data-toggle="dropdown">
		        <i class="fa fa-user-o" aria-hidden="true"></i>
		                    个人中心
		        <b class="caret"></b>
		      </a>
		      <ul class="dropdown-menu" role="menu">
		       		<li><a href="<%=request.getContextPath() %>/Posting/SearchPosting?postman=${user.id}"><span class="glyphicon glyphicon-pencil"></span>
		       		我的帖子</a></li>
		       		<li><a href="<%=request.getContextPath() %>/Domitory/AddDomitory"><i class="fa fa-university" aria-hidden="true"></i>
		       		我的寝室</a></li>
		    		<li><a href="<%=request.getContextPath() %>/Account/ShowMyDetailInfo"><span class="glyphicon glyphicon-user"></span>
		    		我的详情</a></li>
		    		<li><a href="<%=request.getContextPath() %>/Message/GetMessageSendByMe"><span class="glyphicon glyphicon-volume-down"></span>
		    		我的消息</a></li>
		    		<li><a href="<%=request.getContextPath() %>/Questionnaire/GetMyQuestionnaires"><span class="glyphicon glyphicon-envelope"></span>
		    		我的问卷</a></li>
		    		<li><a href="<%=request.getContextPath() %>/Mail/SendEmail"><span class="glyphicon glyphicon-envelope"></span>
		    		我的邮件</a></li>
		      </ul>
		    </li>
			
			<c:if test="${user.administrator eq 1 }">
			<li class="dropdown">
		      <a href="#" class="dropdown-toggle" data-toggle="dropdown">
		        <span class="glyphicon glyphicon-wrench"></span>
		                    后台管理
		        <b class="caret"></b>
		      </a>
		      <ul class="dropdown-menu" role="menu">		    		
		    		<li><a href="<%=request.getContextPath() %>/Info/AddInfo"><span class="glyphicon glyphicon-edit"></span>
		    		信息发布</a></li>
		    		<li><a href="<%=request.getContextPath() %>/Show/AddUniversityShowByDomitory"><span class="glyphicon glyphicon-picture"></span>
		    		展示发布</a></li>	
		    		<li><a href="<%=request.getContextPath() %>/Questionnaire/AddQuestionnaire"><span class="glyphicon glyphicon-list-alt"></span>
		    		创建问卷</a></li>
		    		<li><a href="<%=request.getContextPath() %>/Platform/ComputingPlatform"><i class="fa fa-cloud" aria-hidden="true"></i>
		    		计算中心</a></li>		
		      </ul>
		    </li>
		    </c:if>
		    <li><a href="<%=request.getContextPath() %>/Account/Logout"><span class="glyphicon glyphicon-log-out"></span>
		    注销</a></li>
		  </ul>
  		</div>
		</c:if>

      </div>
    </nav>